<template>
<el-container style="height:100vh; border: 1px solid #eee">
  <el-aside width="200px" style=" background-color:#545c64" v-if="this.$route.name !='login'">
    <el-menu class="leftnav" :default-openeds="['1']"   background-color="#545c64"
      text-color="#fff" router active-text-color="#ffd04b">
      <el-submenu index="1">
        <template slot="title"><i class="el-icon-message"></i>记账本</template>
        <!-- <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="1-1">选项1</el-menu-item>
          <el-menu-item index="1-2">选项2</el-menu-item>
        </el-menu-item-group> -->
          <el-menu-item index="/">简概</el-menu-item>
          <el-menu-item index="/flow">流水</el-menu-item>
          <el-menu-item index="/groupManage">组管理</el-menu-item>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>备忘录</template>
          <el-menu-item index="/newmemo">新建</el-menu-item>
          <el-menu-item index="/allmemo">笔记本</el-menu-item>
      </el-submenu>
    </el-menu>
  </el-aside>
  
  <el-container>
    <el-header style="text-align: right; font-size: 12px;background:whitesmoke;" v-if="this.$route.name !='login'"> 
      <el-dropdown @command="logOut">
        <!-- 头像 -->
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item >注销</el-dropdown-item>
          <!-- <el-dropdown-item>新增</el-dropdown-item>
          <el-dropdown-item>删除</el-dropdown-item> -->
        </el-dropdown-menu>
      </el-dropdown>
      <span>{{nickName}}</span>
    </el-header>
    
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
  
</template>

<style>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
</style>

<script>
  export default {
    data() {
      // const item = {
      //   date: '2016-05-02',
      //   name: '王小虎',
      //   address: '上海市普陀区金沙江路 1518 弄'
      // };
      return {
        // tableData: Array(20).fill(item)
        nickName:this.$store.state.nickName
      }
    },
    methods:{
      logOut() {
        this.$confirm('是否确定退出登录?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$store.commit('LOGOUT')
          this.$router.push('/login')
          })         
      }
    },
    mounted(){
      // console.log('ssssxxxxxxx',this.$store.state.nickName)
      // this.nickName=this.$store.state.nickName
    },
    updated(){
      this.nickName = this.$store.state.nickName
    }
  };
</script>